#ifndef __SMP_BUTTON_H__
#define __SMP_BUTTON_H__

#include "sgl_types.h"
#include "sgl_funcs.h"
#include "sgl_window.h"
#include "res.h"

// SMP button sub functions
enum {
	SMP_BUTTON_SETDATA,
	SMP_BUTTON_SETCHECHED
	//,SMP_BUTTON_WNDPROC
};


typedef struct BTDATA
{
	BOOL hasIcon;
	bmpSt icon;
	PWSTR title;
}BTDATA, *PBTDATA;


#ifndef SDK_NO_PLUGIN
#define SMP_BUTTON_WNDPROC  MPS_CODE_SMP_BUTTON_PROC
#else
#define SMP_BUTTON_WNDPROC  SMP_Button_WndProc
#endif


/**
  \defgroup smp_button Simple Button

  To work with the simple button:
	- Create the button window
	- Set the button title or other necessary information
	- Add to the parent window
	- Response the button notify messages
  
  \code
	//create a button
	hBtn = SGL_CreateWindow(SMP_Button_WndProc, ...);
	SMP_Button_SetTitle(hBtn, SGL_LoadString(STR_OK));
	SGL_AddChildWindow(hWnd, hBtn);

	//response to button notify messages
	case WM_COMMAND:
		WID id = LOWORD(wParam);
		WORD code = HIWORD(wParam);

		if(id == "the button id")
		{
			HWND hBtn = (HWND)lParam;
			switch(code)
			{
			case SMP_BUTTONN_CLICKED:
				//handle the notify event.
				break;
			}
		}	
  \endcode
  
  @ingroup controls
  @{
*/
	/**
	* \name Window Styles
	* @{
	*/

/**
 * \brief Indicate the button is a checkbox button.
 */
#define SMP_BUTTONS_CHECKBOX		0x0001L

/**
 * \brief Indicate the button is a radiobox button.
 */
#define SMP_BUTTONS_RADIOBOX		0x0002L

/**
 * \brief The title is right aligned in horizonal.
 */
#define SMP_BUTTONS_HRIGHT			0x0004L

/**
 * \brief The title is center aligned in horizonal.
 */
#define SMP_BUTTONS_HCENTER			0x0008L

/**
 * \brief The title is center aligned in vertical.
 */
#define SMP_BUTTONS_VCENTER			0x0010L

/**
 * \brief The title is bottom aligned in vertical.
 */
#define SMP_BUTTONS_VBOTTOM			0x0020L

/**
 * \brief Indicates the button is checked.
 */
#define SMP_BUTTONS_CHECKED			0x0040L	

	/** @} */

	/**
	 * \name Window Notify Messages
	 * @{
	 */

/**
 * \brief Sent when button clicked.
 *
 * \code
 *	case WM_COMMAND:
 *		WID id = LOWORD(wParam);
 *		WORD code = HIWORD(wParam);
 *
 *		if(id == "the button id" && code == SMP_BUTTONN_CLICKED)
 *		{
 *			HWND hBtn = (HWND)lParam;
 * 			//handle the button click notify message
 *		}
 * \endcode
 *
 * \param hBtn the button send this message
 */
#define SMP_BUTTONN_CLICKED			0x0001

	/** @} */

	/**
	 * \name Window Member Functions
	 * @{
	 */

#if defined(INCLUDE_IN_PLUG_SGL_SRC) || defined(SDK_NO_PLUGIN)
/**
 * \brief Set the button window title.
 * 
 * \param hBtn the button window handle
 * \param icon the new icon
 * \param title the new title
 */
int32 SMP_Button_SetData(HWND hBtn, bmpSt* icon, PCWSTR str);

/**
 * \brief Check the button.
 * 
 * \param hBtn the button window handle
 * \param checked
 *	- TRUE to check the button
 *	- FALSE to uncheck the button
 */
int32 SMP_Button_SetChecked(HWND hBtn, BOOL checked);

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief The simple button window procedure.	
 *
 * \param hBtn the button window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
LRESULT SMP_Button_WndProc(HWND hBtn, UINT Msg, WPARAM wParam, LPARAM lParam);
#else
/**
 * \brief Set the button window title.
 * 
 * \param hBtn the button window handle
 * \param title the new title
 */
#define SMP_Button_SetData(hBtn, icon, title) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_BUTTON, SMP_BUTTON_SETDATA, (int32)hBtn, (int32)icon, (int32)title, (int32)0, (int32)0)

/**
 * \brief Check the button.
 * 
 * \param hBtn the button window handle
 * \param checked
 *	- TRUE to check the button
 *	- FALSE to uncheck the button
 */
#define SMP_Button_SetChecked(hBtn, checked) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_BUTTON, SMP_BUTTON_SETCHECHED, (int32)hBtn, (int32)checked, (int32)0, (int32)0, (int32)0)

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief The simple button window procedure.	
 *
 * \param hBtn the button window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
#define SMP_Button_WndProc(hBtn, Msg, wParam, lParam) \
	(LRESULT)mrc_extSendAppEventEx(MPS_CODE_SMP_BUTTON_PROC, (int32)hBtn, (int32)Msg, (int32)wParam, (int32)lParam, (int32)0, (int32)0)

#endif

	/** @} */

/** @} end of smp_button */

#endif /* _SMP_BUTTON_H */

